﻿/*1942 game clone
 * Authors:
 * Abdollah Tabareh
 * Bharat Bhushan Konka
 * Martin Svensson 
 * Richard Zianne
 * Tigran Harutyunyan
 * 
 * 2010
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Game1942
{
    class ScoreScene : Scene
    {
        SpriteBatch spriteBatch;
        Texture2D _sprites;
        SpriteFont _fonts;

        public ScoreScene(Game game, Texture2D sp, SpriteFont f): base(game)
        {
            spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
            _sprites = sp;
            _fonts = f;
        }

        public override void  Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            spriteBatch.Draw(_sprites, new Rectangle(0, 0, 800, 600), new Rectangle(943, 707, 80, 60), Color.Wheat);
            spriteBatch.Draw(_sprites, new Vector2(261, 50), new Rectangle(102, 576, 278, 141), Color.White);
            spriteBatch.Draw(_sprites, new Vector2(290, 200), new Rectangle(572, 125, 117, 16), Color.White);
            int[] scores = ScoreManager.readScore();
            int space = 1;
            foreach (int next in scores)
            {
                if (next == 0)
                    continue;
                spriteBatch.DrawString(_fonts, space + ". " + Convert.ToString(next), new Vector2(290, 200 + space * 20), Color.Yellow);
                space++;
                if (space == 16)
                {
                    break;
                }
            }
            spriteBatch.DrawString(_fonts, "Press Esc button to return to the start page", new Vector2(10, 550), Color.White);
            spriteBatch.End();
 	         base.Draw(gameTime);
        }

        public override void Update(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Escape) || keyboardState.IsKeyDown(Keys.Back))
            {
                ((Game1)Game).SetCurrentScene(GameScenes.StartScene);
                
            }
            base.Update(gameTime);
        }

    }
}
